<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">
        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
							<?php echo XXF_LNAME?> 
							选择需要操作的栏目
							<select id="lid"  onchange="lid(this.value)">
							<?php
							     foreach ($list as $row){
							         ?>
							         <option value="<?php echo $row['id']?>" <?php echo $row['id']==$lid?"selected":""?>><?php echo $row['lname']?></option>
							         <?php 
							     }
							?>
							</select>
							<input type="button" value="确定" onclick="sub()">
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th><input type="checkbox" onclick="allornone()" id="checkall"></th>
                                        <th>ID</th>
                                        <th>姓名</th>
                                        <th>职务</th>
                                        <th>手机</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($result as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA" >
                                    	<td><input type="checkbox" <?php echo $row['uid']?"checked":""?> class="onecheck" value="<?php echo $row['id']?>"></td>
                                    	<td><?php echo $row['id'];?></td>
                                        <td><?php echo $row['realname'];?></td>
                                        <td><?php echo $row['zhiwu'];?></td>
                                        <td><?php echo $row['username'];?></td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 1, "asc" ]],
            "aLengthMenu": [ 100, 50, 20, 10 ]
        });
    });
	function allornone(){
		var oc=document.getElementsByClassName("onecheck");
		if($("#checkall")[0].checked){
			for(e of oc){
				e.checked=true;
			}
		}else{
			for(e of oc){
				e.checked=false;
			}
		}
	}
	function lid(lid){
		location.href='qxmanage/type/all/lid/'+lid;
	}
	function sub(){
		$che=$(".onecheck");
		var chall="init";
		$che.each(function(k,v){
			chall+=","+v.value+"_"+((v.checked)?1:0);
		});
		$.xloading(1);
		var send=function(){
			$.post('qxmanage',{
				chall:chall,
				lid:<?php echo $lid?>,
				type:"allsub"
			},function(data){
				$.xloading(0);
				if(data==1){
					$.xalert("操作完成",function(){
						location.reload();
					});
				}
			}).error(function(){
				send();
			});
		}
		send();
	}

    </script>